# Replication Package: Demographics, Innovation, and Cross-Border R&D Capital Allocation

**Paper 24 in the Demographics & Global Capital Allocation series**
**Brian Peters, March 2026**

---

## Overview

This paper tests whether aging reshapes innovation investment and output. Key findings: aging countries spend more on R&D (old_dep = +5.31***) but produce less high-tech output (Z₁ = -75.3**, bootstrap robust). Cross-border FDI does not compensate. Patent evidence is suggestive but fragile under cluster bootstrap (p = 0.50).

## Software Requirements

- Python 3.10+
- Required packages: `numpy`, `pandas`, `statsmodels`, `scipy`, `matplotlib`, `python-docx`
- Install: `pip install numpy pandas statsmodels scipy matplotlib python-docx`

## Directory Structure

```
replication/
  REPLICATION_README.md
  scripts/
    phase1_data_assembly.py      # Data assembly (merges R&D, patents, demographics)
    phase2_baseline.py           # Baseline innovation regressions
    phase3_mechanisms.py         # Mechanism tests (human capital, health, manufacturing)
    phase4_efficiency_puzzle.py  # Innovation efficiency analysis
    phase5_referee_fixes.py      # Referee-requested robustness
    build_docx.py                # DOCX generation
  src/
    model.py                     # PanelGLS estimator (shared across series)
    [other shared modules]
  data/
    processed/
      innovation_panel.csv       # Processed panel (R&D, patents, demographics)
    raw/
      wdi_innovation.csv         # WDI R&D expenditure data
      wdi_manufacturing.csv      # WDI manufacturing value added
      wdi_researchers.csv        # WDI researchers per million
  output/tables/
    [28 markdown tables]         # All regression output
  paper/
    paper.md                     # Manuscript source
```

## Reproduction

Run scripts in order:
```bash
python3 scripts/phase1_data_assembly.py
python3 scripts/phase2_baseline.py
python3 scripts/phase3_mechanisms.py
python3 scripts/phase4_efficiency_puzzle.py
python3 scripts/phase5_referee_fixes.py
```

**Note:** Scripts use absolute paths (`/mnt/c/demographics_capital_flows/...`). Update the path references at the top of each script for your local environment.

## Data Sources

- UN World Population Prospects (2024 Revision) — age distributions
- World Bank WDI — R&D expenditure, researchers, manufacturing VA, high-tech exports
- WIPO — patent applications by origin
- OECD — cross-border R&D FDI
- IMF WEO — GDP, fiscal balance
- Penn World Table 10.01 — output per worker
